/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package databeans;

import beans.HistoricoBean;
import com.sun.rowset.CachedRowSetImpl;
import javax.sql.rowset.CachedRowSet;
import utils.CargarConfiguraciones;

/**
 *
 * @author Eduardo Cerritos
 */
public class HistoricoDataBean {
    
    private CachedRowSet rowSet;
    private CargarConfiguraciones cc;
    
    public HistoricoDataBean() throws Exception
    {
        cc = new CargarConfiguraciones();
        Class.forName(cc.getValor("driver"));
        rowSet = new CachedRowSetImpl();
        rowSet.setUrl(cc.getValor("urlbase"));
        rowSet.setUsername(cc.getValor("usuario"));
        rowSet.setPassword(cc.getValor("clave"));
    }

    public void setHistorico(HistoricoBean historico) throws Exception
    {
        String sql = "INSERT INTO historico_encuesta(" +
                "idencuesta,usuario,ciclo) values(" +
                "'" + historico.getEncuesta() + "', " +
                "'" + historico.getUsuario() + "', " +
                "'" + historico.getCiclo()+ "')";

        System.out.println(sql);

        rowSet.setCommand(sql);

        rowSet.execute();
    }

}
